<!DOCTYPE html>
<html lang="">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button>赞(0)</button>
    <button>赞(0)</button>
    <button>赞(0)</button>
    <button>赞(0)</button>
    <script>
      let btns = document.querySelectorAll("button");
      for (var i = 0; i < btns.length; i++) {
        (function (i) {
          var num = 0;
          btns[i].onclick = function () {
            num++;
            btns[i].innerText = `赞 (${num})`;
          };
        })(i);
      }
      let a = 10;
      console.log("a: ", a);
    </script>
  </body>
</html>
